package interceptor.dataValid;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import vo.admin.AddUserPanelVO;
import vo.admin.LoginPanelVO;
import vo.admin.MainPanelVO;
import vo.admin.ModifyUserPanelVO;
import logic.AdminLogic;
import logicInterface.AdminLogicInterface;

public class AdminDataValid extends UnicastRemoteObject implements AdminLogicInterface,Serializable{
	private AdminLogicInterface logic;

	public AdminDataValid() throws RemoteException{
		
	}
	
	public AdminDataValid(AdminLogic adminLogic) throws RemoteException{
		logic=adminLogic;
	}

	@Override
	public String getMessage() throws RemoteException {
		// TODO Auto-generated method stub
		return logic.getMessage();
	}

	@Override
	public String getState() throws RemoteException {
		// TODO Auto-generated method stub
		return logic.getState();
	}

	@Override
	public String login() throws RemoteException{
		LoginPanelVO lpvo=logic.getLpvo();
		if(lpvo.getUsername().equals("")||lpvo.getPassword().equals("")){
			setMessage("用户名和密码不能为空！");
			return logic.getState();
		}
		return logic.login();
	}

	@Override
	public String logout() throws RemoteException {
		// TODO Auto-generated method stub
		return logic.logout();
	}

	@Override
	public String searchUser() throws RemoteException {
		// TODO Auto-generated method stub
		return logic.searchUser();
	}

	@Override
	public String addUser() throws RemoteException {
		AddUserPanelVO aupvo=logic.getAupvo();
		if(aupvo.getUsername().equals("")||aupvo.getPassword().equals("")){
			setMessage("用户名和密码不能为空！");
			return logic.getState();
		}
		return logic.addUser();
	}

	@Override
	public String modifyUser() throws RemoteException{
		ModifyUserPanelVO mupvo=logic.getMupvo();
		if(mupvo.getPassword().equals("")){
			setMessage("密码不能为空！");
			return logic.getState();
		}
		return logic.modifyUser();
	}

	@Override
	public String toAddUser() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.toAddUser();
	}

	@Override
	public String toModifyUser() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.toModifyUser();
	}

	@Override
	public String deleteUser() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.deleteUser();
	}

	@Override
	public String toMain() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.toMain();
	}

	@Override
	public LoginPanelVO getLpvo() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.getLpvo();
	}

	@Override
	public MainPanelVO getMpvo() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.getMpvo();
	}

	@Override
	public AddUserPanelVO getAupvo() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.getAupvo();
	}

	@Override
	public ModifyUserPanelVO getMupvo() throws RemoteException{
		// TODO Auto-generated method stub
		return logic.getMupvo();
	}

	@Override
	public void setMessage(String s) throws RemoteException{
		// TODO Auto-generated method stub
		logic.setMessage(s);
	}

	@Override
	public void setState(String s) throws RemoteException{
		// TODO Auto-generated method stub
		logic.setState(s);
	}

	@Override
	public void setLpvo(LoginPanelVO lpvo) throws RemoteException{
		logic.setLpvo(lpvo);
	}

	@Override
	public void setMpvo(MainPanelVO mpvo) throws RemoteException {
		logic.setMpvo(mpvo);
	}

	@Override
	public void setAupvo(AddUserPanelVO aupvo) throws RemoteException {
		logic.setAupvo(aupvo);
	}

	@Override
	public void setMupvo(ModifyUserPanelVO mupvo) throws RemoteException {
		logic.setMupvo(mupvo);
	}

}
